function throttle(func, delay) {  
  let lastCall = 0;  
  return function(...args) {  
    const now = new Date().getTime();  
    if (now - lastCall < delay) {  
      return;  
    }  
    lastCall = now;  
    return func.apply(this, args);  
  };  
}  
// 创建自定义指令  
const throttleDirective = {  
  mounted(el, binding) {  
    const { value, arg } = binding;  
    el.addEventListener(arg || 'click', throttle(value, 3000)); // 假设默认事件为 click，节流时间为 200ms  
  },  
  // unmounted(el, binding) {  
  //   // const { arg } = binding;  
  //   // el.removeEventListener(arg || 'click');  
  // },  
};  
  
export default throttleDirective;